
declare let require:any;
var monitor = require("monitor");
import basePanleScript from "../../base/basePanleScript";
import gameModel from "../gameScene/gameModel";
import AudioUtils from "../AudioUtils";

const { ccclass, property } = cc._decorator;

@ccclass
export default class mainScene extends basePanleScript {
    public onLoaded(param: any): void {
        // throw new Error("Method not implemented.");
    }
    public onEnter(param: any): void {
        // throw new Error("Method not implemented.");
    }
    public onRefresh(param: any): void {
        // throw new Error("Method not implemented.");
    }
    private touchEven(event) {
        var btnName=event.target.name;
        switch(btnName){
            case "btn_duZou":
                console.log("打开独奏")
                gameModel.getInstance().gameType=1;
                (<any>window).CustomEventManager.trigger({type:"gameState",content:{state:"startGame"}})
            break;
            case "btn_battle":
                gameModel.getInstance().gameType=3;
                this.showToast("暂未开放")
            break;
            case "btn_chongzou":
                gameModel.getInstance().gameType=2;
                this.showToast("暂未开放")
            break;
        }
        AudioUtils.getInstance().playEffect("button.wav")
    }
    // onload(){
    //     gameModel.getInstance();
    // }
    // handler(data){

    // }
    onEnable(){
        AudioUtils.getInstance().playBgMusic("menu.mp3");
        this.node.on(cc.Node.EventType.TOUCH_END,this.touchEven,this,true)
        // (<any>window).EventListener.on("getScore",this.hander.bind(this));

        
    }
    onDisable(){
        this.node.off(cc.Node.EventType.TOUCH_END,this.touchEven,this,true);
        // (<any>window).EventListener.off("getScore",this.hander.bind(this));
    }
    
}
